﻿using System;
using Csla.Rules;
using BizControl.Library.BusinessObjects;
using BizControl.Resources;

namespace BizControl.Library.CommonBizRules
{
  internal class ValueCantBeEmpty : BusinessRule
  {
    protected override void Execute(RuleContext context)
    {
      foreach (var property in context.InputPropertyValues)
      {
        var asEmpty = property.Value as ISupportEmptyValue;
        if (asEmpty != null && asEmpty.IsEmpty())
          context.AddErrorResult(string.Format(ValidationErrors.EmptyValueError, property.Key.FriendlyName));
      }
    }
  }
}
